package com.hubery.designpattern.event.listener;

import com.hubery.designpattern.design.strategy.SendMessageStrategySupport;
import com.hubery.designpattern.design.strategy.dto.SendMessageDTO;
import com.hubery.designpattern.enums.MessagePlatformTypeEnum;
import com.hubery.designpattern.event.ActivityNotifyUserEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author lixueyang
 * @since 2023/2/28 11:49
 */
@Slf4j
@Component
public class ActivityNotifyUserEventListener extends SendMessageStrategySupport {

    @EventListener
    public void handle(ActivityNotifyUserEvent activityNotifyUserEvent) {

        SendMessageDTO dto = new SendMessageDTO();
        dto.setUserInfoDTO(activityNotifyUserEvent.getUserInfoDTO());
        dto.setMsg(activityNotifyUserEvent.getMsg());

        //发送短信
        getSendMessageStrategyService(MessagePlatformTypeEnum.SMS).send(dto);
    }
}
